import multiprocessing
import datetime
import logging

def cal(i):
    a = 0
    for _ in range(1000000):
        a += 1
        print(a)
    return i, a

if __name__ == '__main__':
    star = datetime.datetime.now()
    pool = multiprocessing.Pool(4)
    for i in range(4):
        ret = pool.apply(cal, args=(i,))
        print(ret)
    pool.close()
    pool.join()
    cost = datetime.datetime.now() - star
    print(cost)
